#some classes we care about
people
directions <- c("straight","up","left","right")
emotions <- c("neutral","happy","sad","angry")

#a different case (boolean)
sunglasses <- c("sunglasses","open")

#little helper to get the types right
grepper <- function(person,TrainingData) {
  matrix(grepl(person,TrainingData))
}

# Params:
#   properties: a matrix of strings (nx1)
#   TrainingData: a vector of file names of images
# Returns:
#   A matrix of row vectors. For each vector v_i, its j-th component 
#     v_{ij} = TRUE  if the j-th file in TrainingData has property i, 
#            = FALSE if the j-th file in TrainingData lacks property i
getIndividualBinaryLabels <- function(properties, TrainingData) {
  t(apply(matrix(properties),1,grepper,TrainingData))
}

#for use with sunglasses
getSingleBinaryLabel <- function(properties, TrainingData) {
  t(grepper(properties[1,1],TrainingData))
}

#getIndividualBinaryLabels <- function(people, TrainingData){
#  numPpl = length(people)
# numTrainData = length(TrainingData)
#  
#  result = matrix(0, numPpl, numTrainData)
#  
#  for (i in 1:numPpl){    
#    for (j in 1:numTrainData){
#      # grab the name of the person in TrainingData[j]
#      dataName = gsub(".*faces/(.*)/.*", "\\1", TrainingData[j])
#      
#      if(dataName == people[i]){
#        result[i, j] = 1
#      } else {
#        result[i, j] = -1
#      }
#    }    
#  }
#  
#  return (result)
#}

###############################
# Test
###############################

#people <- c("ben", "jerry", "cameron")
#TrainingData <- c("faces/sunglasses/f1", "faces/open/f1", "faces/open/f1", "faces/sunglasses/f2")
#print(getIndividualBinaryLabels(matrix(sunglasses), TrainingData))
